package com.chainyoung.component_tmperson.ui.mvp.presenter;

import com.chainyoung.common.base.CommonSubscriber;
import com.chainyoung.common.mvp.BasePresenter;
import com.chainyoung.common.utils.RxUtils;
import com.chainyoung.component_tmperson.entity.DebitRepay;
import com.chainyoung.component_tmperson.entity.WalletRepayment;
import com.chainyoung.component_tmperson.ui.mvp.contract.WalletDebitRepayRecordContract;
import com.chainyoung.component_tmperson.ui.mvp.contract.WalletRepaymentScheduleContract;

import java.util.List;
import java.util.TreeMap;

import javax.inject.Inject;

public class WalletDebitRepayRecordPresenter extends BasePresenter<WalletDebitRepayRecordContract.Model, WalletDebitRepayRecordContract.View> {

    @Inject
    public WalletDebitRepayRecordPresenter(WalletDebitRepayRecordContract.Model model, WalletDebitRepayRecordContract.View rootView) {
        super(model, rootView);
    }


    public void getRepaymentScheduleList(TreeMap<String, Object> map) {

        addSubscribe(mModel.getDebitRecord(map)
                .compose(RxUtils.<DebitRepay>rxSchedulerHelper())
                .subscribeWith(new CommonSubscriber<DebitRepay>(mView, false) {
                    @Override
                    public void onNext(DebitRepay data) {
                        mView.onGetOwnWalletRecordSuccessed(data);
                    }

                    @Override
                    public void onError(Throwable e) {
                        mView.onGetOwnWalletRecordFailed();
                        super.onError(e);
                    }
                }));
    }

}


